<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<%@ page import="java.io.*"%>
<%@ page import="requestInterFace.Handle.*"%>
<%@ page import="xml.response.*"%>
<%@ page import="xml.root"%>
<%@ page import="util.print.printLogCat"%>
<%@ page import="org.sql.table.*"%>
<%@ page import="xml.var"%>
<%@ page import="java.util.Vector"%>
<%@ page import="java.util.Enumeration"%>
<%@ page import="requestInterFace.UserInfoInterFace.*"%>
<%@ page import="jqgrid.jqgrid"%>
<%@ page import="org.util.getNewData"%>
<%@ page import="util.check"%>
<%@ include file="../../util/paramPrint.jsp" %>

<%@ page trimDirectiveWhitespaces="true" %> 
<%   

    /*********** jqgrid ******************/
		jqgrid jq=new jqgrid();
		jq.setRows(request.getParameter(jqgrid._rows));
		jq.setSord(request.getParameter(jqgrid._sord));
		jq.setSortname(request.getParameter(jqgrid._sortname));
		jq.setPage(request.getParameter(jqgrid._page));
		jq.setOper(request.getParameter(jqgrid._oper));
		jq.setSearch(request.getParameter(jqgrid._search));
		/*************************************/
String ID = request.getParameter("ID");
String User_ID = request.getParameter("User_ID");
String Advice_Content = request.getParameter("Advice_Content");
String Advice_BackContent = request.getParameter("Advice_BackContent");
String userType=(String)session.getAttribute("User_Type");
String userID=(String)session.getAttribute("User_ID");
root root=new root();
       
		if(ID==null||ID.equals("")){
		root.setStatus("false");
		root.setMsg("请输入要修改的ID");
		PrintWriter pw = response.getWriter();
		pw.println(root.getXmlString());
		pw.flush();
		return ;
		}
		adviceinfo1_1 user=new adviceinfo1_1();
        if(userType!=null&&userType.equals("1")){
			//管理员
			user.addequwhile("ID"," = ",ID);
			user.addequwhile("User_ID"," = ",User_ID);
		}else if(userType!=null&&userType.equals("2")){
			//业务员
			adviceHandle handle=new adviceHandle();
			if(handle.isUP(userID,ID)){
			user.addequwhile("ID"," = ",ID);
			user.addequwhile("User_ID"," = ",User_ID);
			}else{
			root.setStatus("false");
			root.setMsg("没有修改权限");
			PrintWriter pw = response.getWriter();
			pw.println(root.getXmlString());
			pw.flush();
			return ;
			}
		}else if(userType!=null&&userType.equals("3")){
			//客户
			adviceHandle handle=new adviceHandle();
			if(userID.equals(User_ID)){
			user.addequwhile("ID"," = ",ID);
			user.addequwhile("User_ID"," = ",User_ID);
			}else{
			root.setStatus("false");
			root.setMsg("没有修改权限");
			PrintWriter pw = response.getWriter();
			pw.println(root.getXmlString());
			pw.flush();
			return ;
			}
		}
		
		if(Advice_Content!=null&&(!Advice_Content.equals(""))){
		  
		    user.setUpdateField("Advice_Content",Advice_Content);
		}
		
		if(Advice_BackContent!=null&&(!Advice_BackContent.equals(""))){
		  
		    user.setUpdateField("Advice_BackContent",Advice_BackContent);
			user.setUpdateField("Advice_BackTime",getNewData.GetNowDateAndTime1());
			user.setUpdateField("BackUser_ID",userID);
		}
	   
		int row=user.updata();
		root.setRecords(""+row);//设置当前查询到的记录数
		if(row>0){
			root.setStatus("true");
			root.setMsg("修改成功");
		}else{
			root.setStatus("false");
			root.setMsg("修改失败");
		}
		//printLogCat.printlnWriter(root.getXmlString());
		String rep=root.getXmlString();
%>
<%=rep%>


